<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('维度管理')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body>
<div class="wrapper wrapper-content">
    <table id="mainTable"></table>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
    var prefix = ctx + "system/dataauth";
    var tableName = "[[${tableName}]]";
    var userId = "[[${userId}]]";
    function submitHandler() {
        debugger;
        var rows = $("#mainTable").bootstrapTable('getSelections');
        if(rows.length==0) {
            $.modal.alertError("至少需要选择一条数据");
            return ;
        }
        var dims = [];
        $.each(rows,function (index,item) {
            dims.push({"sdDataauthType":tableName,"userId":userId,"dataauthCd":item.cd,"dataauthName":item.na});
        });
        $.ajax({
            url: prefix+"/addList",
            cache: false,
            async: false,
            type: 'POST',
            dataType: 'json',
            data: JSON.stringify(dims),
            contentType: 'application/json;charset=UTF-8',
            success: function (result) {
                if(result.code=="0") {
                    $.modal.close();
                }
            }
        });
    }

    $(function(){
        $(function() {
            $('#mainTable').bootstrapTable({
                url: "/md/med/dim/findDimData2/"+tableName,
                method: "get",
                modalName: "定时任务",
                showToggle: false,
                showColumns: false,
                pagination: false,
                search: false,
                sidePagination: 'client',
                showRefresh: true,
                search: true,
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'cd',
                        title: '编码',
                    },
                    {
                        field: 'na',
                        title: '名称',
                        sortable: true
                    },
                    {
                        field: 'des',
                        title: '备注'
                    }]
            });
        });
    });
</script>
</body>
</html>